package com.coinland.study.base;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * 类描述:
 * 创建人:  shenZ
 * 创建时间: 2019/8/22
 * 联系方式: 252079249@qq.com
 * 修改时间: 2019/8/22
 */
public abstract class BaseFragment extends Fragment{

    private Unbinder unbinder;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(this.getLayoutId(),container,false);
        unbinder = ButterKnife.bind(this,view);
        initView(view);

        return view;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }

    /**
     * 初始化视图
     *
     * @param view
     */
    protected abstract void initView(View view);



    protected abstract int getLayoutId();
}
